package com.project.controller;

import com.project.bean.ReplyBean;
import com.project.bean.UserBean;
import com.project.servic.IReplyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@RestController
@RequestMapping("reply")
public class ReplyController {
    @Autowired
    private IReplyService service;
    @RequestMapping("add")
    public List<ReplyBean> add (String replyContent, Integer post, HttpServletRequest req){
        //从session中得到登陆用户
        UserBean user = (UserBean) req.getSession().getAttribute("loginUser");
        ReplyBean replyBean = new ReplyBean(replyContent,user.getId(),post);
        List<ReplyBean>list = service.add(replyBean);
        return list;
    }
}
